<?php

	require_once("scripts/dbconnection.php");
	
	$authorID = mysql_query("SELECT AuthorID FROM AUTHOR WHERE AuthorName = '" . $_POST["authorBox"] . "'");
	$temp = mysql_fetch_assoc($authorID);
	
	$addBook = mysql_query("INSERT INTO BOOK VALUES(null, '" . $_POST["callNoBox"] . "', '" . $_POST["titleBox"] . "', '" . $_POST["ISBNBox"] . "', " . $temp["AuthorID"] . ", '" . $_POST["publisherBox"] . "', '" . $_POST["descBox"] . "')");
	
	$errVar = mysql_error();
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>eLibrary Administration : Add Book Confirmation</title>
		<link href="style/defaults.css" rel="stylesheet" type="text/css" media="all" />
		<link href="style/elements.css" rel="stylesheet" type="text/css" media="all" />
	</head>
	<body>
		
		<div class="header">
			<h1><a href="index.php">eLibrary</a></h1>
			<h3>Administer your library.</h3>
		</div>
		
		<div class="container">
			<h2>Add a book.</h2>

			<?php	
			
				if (strlen($errVar) > 1)
				{
					echo "Some of your input seems to be invalid. Please check all your data and try again.";
			?>
				<p>Click <a onclick="javascript:history.back(-2)" alt="Go Back" id="linkBack">here</a> to go back and change your input.</p>
			<?php
				}
				else
				{
					echo "Book added successfully.";
			}
					
				echo "<br /><br />Author: " . $_POST["authorBox"];
				echo "<br />Title: " . $_POST["titleBox"];
				echo "<br />Call No: " . $_POST["callNoBox"];
				echo "<br />ISBN: " . $_POST["ISBNBox"];
				echo "<br />Publisher: " . $_POST["publisherBox"];
				echo "<br />Description: " . $_POST["descBox"];
			
			?>

		</div>
	</body>
</html>
	